/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sonth.BLL;

import sonth.EL.Product;
import sonth.DAL.ProductDAO;
import java.util.List;
import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public final class ProductService {

    /**
     * desc.
     */
    private ProductService() {
    }

    /**
     * desc.
     * @return List<Product> desc
     */
    public static List<Product> getAll() {
        List<Product> products = new ArrayList<Product>();
        try {
            products = ProductDAO.selectAll();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return products;
    }

    /**
     * desc.
     * @param keyword desc
     * @return List<Product> desc
     */
    public static List<Product> getByName(final String keyword) {
        List<Product> products = new ArrayList<Product>();
        try {
            products = ProductDAO.selectByName(keyword);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return products;
    }

    /**
     * desc.
     * @param range desc
     * @return List<Product> desc
     */
    public static List<Product> getByAlphabetName(final String range) {
        List<Product> products = new ArrayList<Product>();
        try {
            products = ProductDAO.selectByAlphabetName(range);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return products;
    }

    /**
     * desc.
     * @param product desc
     * @return boolean desc
     */
    public static boolean add(final Product product) {
        boolean result = false;
        try {
            result = ProductDAO.insert(product);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return result;
    }
}
